package com.nets.packet;

import com.nets.util.LogUtil;

/**
 * @author sig
 * @since 2016/9/17
 */
public class Packet
        extends AbstractPacket {

    public Packet() {
    }

    public Packet(PacketType req) {
        setPacketType(req);
        put("mark", 1);
    }

    public Packet(PacketType req, int mark) {
        setPacketType(req);
        put("mark", mark);
    }

    public Packet(Packet req) {
        setPacketType(req.getPacketType());
        put("mark", 1);
    }

    public Packet(Packet req, int mark) {
        setPacketType(req.getPacketType());
        put("mark", mark);
    }

    @Override
    public void run() {
        try {
            Invoke invoke = getPacketType().getInvoke();

            if (null != invoke) invoke.invoke(new Object(), this);
        } catch (Exception e) {
            LogUtil.console.error(e.getMessage(), e);
        }
    }
}
